/*
package com.wgj.android.web;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebBackForwardList;
import android.widget.LinearLayout;

import com.jiaai.xui.view.widget.XTopbarView;
import com.just.agentweb.AgentWeb;
import com.wgj.android.R;
import com.wgj.android.widget.imageselect.ImagePicker;

import butterknife.BindView;
import butterknife.ButterKnife;

*/
/**
 * Created by Administrator on 2017/10/27.
 *//*

public class XXXWebActivity extends AppCompatActivity {
    public static final String WEB_CONFIG = "web_config";
    @BindView(R.id.webviewWarp)
    LinearLayout webviewWarp;
    @BindView(R.id.topBar)
    XTopbarView topBar;
    private AgentWeb mAgentWeb;
    private String url;
    private AndroidInterface androidInterface;
    private ImagePicker imagePicker;
    private String title;

    public static void getINT(Context context, String url, String title) {

        Intent intent = new Intent(context, XXXWebActivity.class);
        intent.putExtra("url", url);
        if (title != null) {
            intent.putExtra("title", title);
        }

        context.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        title = getIntent().getStringExtra("title");
        url = getIntent().getStringExtra("url");
        setContentView(R.layout.xxx_web_view);
        //AndroidBugWorkaround.assistActivity(this);
        ButterKnife.bind(this);


        initView();
    }

    public void initView() {
        if(title!=null){
            topBar.setVisibility(View.VISIBLE);
            topBar.setTitle(title);
        }

        mAgentWeb = AgentWeb.with(this)//传入Activity or Fragment
                .setAgentWebParent(webviewWarp, new LinearLayout.LayoutParams(-1, -1))
                .setIndicatorColorWithHeight(ContextCompat.getColor(this, R.color.colorPrimary), 1)// 使用默认进度条
                .createAgentWeb()
                .ready()
                .go(url);
        mAgentWeb.getWebCreator().getWebView().setHorizontalScrollBarEnabled(false);
        mAgentWeb.getWebCreator().getWebView().setVerticalScrollBarEnabled(false);
        androidInterface = new AndroidInterface(mAgentWeb, this);
        mAgentWeb.getJsInterfaceHolder().addJavaObject("android", androidInterface);

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == 1000) {
            mAgentWeb.getWebCreator().getWebView().loadUrl(url);
            return;
        }
        androidInterface.onActivityResult(requestCode, resultCode, data);
        // mAgentWeb.getJsAccessEntrace().quickCallJs("window.onSelecttMapCallback();
    }

    @Override
    protected void onPause() {
        // mAgentWeb.getWebLifeCycle().onPause(); //暂停应用内所有 WebView ， 需谨慎。
        super.onPause();

    }

    @Override
    protected void onResume() {
        mAgentWeb.getWebLifeCycle().onResume();
        super.onResume();
    }

    @Override
    protected void onDestroy() {
        mAgentWeb.getWebLifeCycle().onDestroy();
        super.onDestroy();
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_BACK:
                    */
/*if (mAgentWeb.getWebCreator().getWebView().canGoBack()) {
                        mAgentWeb.getWebCreator().getWebView().goBack();
                        return true;
                    } else {
                        finish();
                        return true;
                    }*//*


                   */
/* WebBackForwardList history = mAgentWeb.getWebCreator().getWebView().copyBackForwardList();
                    int index = -1;
                    String url = null;
                    String currentUrl = mAgentWeb.getWebCreator().getWebView().getUrl();
                    while (mAgentWeb.getWebCreator().getWebView().canGoBackOrForward(index)) {
                        int currentIndex = history.getCurrentIndex();
                        String lastUrl = history.getItemAtIndex(currentIndex + index).getUrl();
                        if (!currentUrl.equals(lastUrl)) {
                            mAgentWeb.getWebCreator().getWebView().goBackOrForward(index);
                            url = lastUrl;
                            break;
                        }
                        index--;

                    }
                    if (url == null) {
                        onBackPressed();
                    }
                    if (history.getSize() == 2) {
                        onBackPressed();
                    }
                    return true;*//*


                    if (mAgentWeb.getWebCreator().getWebView().canGoBack()) {
                        //获取webView的浏览记录
                        WebBackForwardList mWebBackForwardList = mAgentWeb.getWebCreator().getWebView().copyBackForwardList();
                        //这里的判断是为了让页面在有上一个页面的情况下，跳转到上一个html页面，而不是退出当前activity
                        if (mWebBackForwardList.getCurrentIndex() > 0) {
                            String historyUrl = mWebBackForwardList.getItemAtIndex(mWebBackForwardList.getCurrentIndex()).getUrl();
                            if (!historyUrl.equals(url)) {
                                mAgentWeb.getWebCreator().getWebView().goBack();
                                return true;
                            }
                        }
                    } else {

                        onBackPressed();
                    }
            }

        }
        return super.onKeyDown(keyCode, event);
    }


}
*/
